<template>
	<sc-table-select
		ref="tableselect"
		v-model="goodsvalue"
		:attrList="attrList"
		:valueList="valueList"
		:queryList="queryList"
		:orderList="orderList"
		:orgCode="orgCode"
		:brandCode="brandCode"
		:table-width="640"
		collapse-tags
		collapse-tags-tooltip
		:props="props"
		@change="change"
	>
		<template #header="{}">
			<el-form :inline="true">
				<el-row :gutter="5"
					><el-col :span="5">
						<el-input
							v-model="queryList.GoodsCode"
							placeholder="请输入物品编码"
							style="width: 125px"
						></el-input></el-col
					><el-col :span="5">
						<el-input
							v-model="queryList.GoodsName2"
							placeholder="请输入物品名称"
							style="width: 125px"
						></el-input> </el-col
					><el-col :span="5"
						><el-select
							v-model="queryList.UomCode"
							placeholder="请选择单位"
                            clearable
							:teleported="false"
							style="width: 120px"
						>
							<el-option
								label="---请选择---"
								value=""
							></el-option>
							<el-option
								v-for="item in optionsUomCode"
								:key="item.value"
								:label="item.label"
								:value="item.value"
							/> 
                        </el-select></el-col
					><el-col :span="5">
						<el-select
							v-model="queryList.State"
							placeholder="请选择状态"
							clearable
							:teleported="false"
							style="width: 120px"
						>
							<el-option label="---请选择状态---" value="" />
							<el-option label="禁用" value="0" />
							<el-option
								label="启用"
								value="1"
							/> </el-select></el-col
					><el-col :span="4">
						<el-button type="primary" @click="opBindData()"
							>查询</el-button
						></el-col
					></el-row
				>
			</el-form>
		</template>
		<el-table-column
			prop="GoodsCode"
			label="物品编码"
			width="100"
		></el-table-column>
		<el-table-column
			prop="GoodsName"
			label="物品名称"
			width="150"
		></el-table-column>
		<el-table-column
			prop="UomName"
			label="单位"
			width="120"
		></el-table-column>
		<el-table-column
			prop="CostPrice"
			label="成本价"
			width="120"
		></el-table-column>
		<el-table-column
			prop="SalePrice"
			label="销售价"
			width="120"
		></el-table-column>
		<el-table-column
			prop="State"
			label="状态"
			width="100"
		></el-table-column>
	</sc-table-select>
</template>

<script>
import publicjs from "@/api/model/publicjs";
export default {
	name: "goodsPriceSelect",
	components: {
		publicjs,
	},
	props: {
		orgCode: { type: String, default: "" },
		brandCode: { type: String, default: "" },
	},
	data() {
		return {
			attrList: {
				Name: "BrandGoodsPrice",
				UseDistinct: false,
				OrgCode: "",
				UseBackUp: false,
				UseGroup: false,
			},
			valueList: {
				ItemCode: "ItemCode",
				GoodsCode: "GoodsCode",
				GoodsName2: "GoodsName",
				UomCode: "UomCode",
				UomName: "UomName",
				CostPrice: "CostPrice",
				SalePrice: "SalePrice",
				State: "State",
			},
			queryList: {
				OrgCode: this.orgCode,
				BrandCode: this.brandCode,
				GroupTypeCode: "046002,046003",
				GoodsCode: "",
				GoodsName2: "",
				UomCode: "",
				State: "",
			},
		};
	},
	methods: {
		async opBindData() {
			//this.$refs.tableselect.clearSort();
			this.$refs.tableselect.getData();
		},

		async initOptions() {
			var head = new publicjs.head();
			publicjs.initHead(head, "getfirstdatasource");
			var ed = new publicjs.entitydata(head);
			var eo = new publicjs.entityobj();
			eo.AttrList = {
				Name: "GoodsPrice",
				AcceptControl: "UomCode",
				OrgCode: "",
			};
			ed.Data.Content.ObjectList.Object.push(eo);
			try {
				var returnValueStr = await this.$API.auth.objProcess.post(ed);
				var returnValue = JSON.parse(returnValueStr);
				// eslint-disable-next-line no-debugger
				//debugger;
				console.log(returnValue.content);
				if (returnValue.Result.OpFlag == "1") {
					var objectList =
						returnValue.Result.Content.ObjectList.Object;
					this.optionsUomCode = objectList.rows.row;
				}
			} catch (error) {
				this.loading = false;
				this.$alert(error.message, "提示", { type: "error" });
				return false;
			}
		},
	},
	computed: {},
	mounted() {
		this.initOptions();
		this.opBindData();
	},
};
</script>

<style scoped></style>
